/**
 * CoffeeMilk (C) 2010 Amen Hamdan
 * 
 * See the NOTICE file distributed with this work for additional 
 * information regarding copyright ownership.  This file is licenses
 * to you under the Apache License, Version 2.0 (the "License"); you 
 * may not use this file except in compliance with the License.  You 
 * may obtain a copy of the License at
 * 
 *     http://www.apache.org/licenses/LICENSE-2.0
 *     
 * Unless required by applicable law or agreed to in writing, software 
 * distributed under the License is distributed on an "AS IS" BASIS, 
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 
 * implied. See the License for the specific language governing 
 * permissions and limitations under the License.    
 * 
 */
package ameen.rtm.lib.types;

import java.io.Serializable;

import org.codehaus.jackson.JsonNode;

public class AuthToken implements Serializable {
	private static final long serialVersionUID = -744027984331534658L;
	
	private String token;
	private String userName;
	private String fullName;
	private String id;

	public String getUserName() {
		return userName;
	}

	public void setUserName(String userName) {
		this.userName = userName;
	}

	public String getFullName() {
		return fullName;
	}

	public void setFullName(String fullName) {
		this.fullName = fullName;
	}

	public static long getSerialversionuid() {
		return serialVersionUID;
	}

	public void setToken(String token) {
		this.token = token;
	}

	public void setId(String id) {
		this.id = id;
	}

	public AuthToken() {
	}
	
	public String getToken() {
		return token;
	}

	public String getUsername() {
		return userName;
	}

	public String getFullname() {
		return fullName;
	}

	public String getId() {
		return id;
	}

	public AuthToken(JsonNode jsonNode) {
		JsonNode node = jsonNode.get("auth");
		
		token 		= node.get("token").getTextValue();
		id 			= node.get("user").get("id").getTextValue();
		userName 	= node.get("user").get("username").getTextValue();
		fullName 	= node.get("user").get("fullname").getTextValue();
	}
}
